/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package example.piechart;

import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PiePlot3D;
import org.jfree.data.general.DefaultPieDataset;

/**
 * 
 * @author Teledhil
 */
public class PieChart extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 3424887965327553015L;

	public PieChart() {

		// JPanel panel = new JPanel(); hola!
		super();

		DefaultPieDataset dataset = new DefaultPieDataset();
		dataset.setValue("Rojas", 45);
		dataset.setValue("Azules", 80);
		dataset.setValue("Verdes", 42);
		dataset.setValue("Amarillas", 15);

		//JFreeChart chart = ChartFactory.createPieChart3D("Piezas montadas", dataset,
		//		false, false, false);
		JFreeChart chart = ChartFactory.createPieChart3D("Piezas montadas", dataset, true, true, false);
		PiePlot3D plot = (PiePlot3D) chart.getPlot();
		plot.setForegroundAlpha(0.6f);
		plot.setCircular(true);
		
		ChartPanel chartPanel = new ChartPanel(chart, 250, 150, 250, 150, 250, 150, true, false, true, true, false, false);
		//chartPanel.setPreferredSize(new Dimension(250, 150));
		//chartPanel.setMaximumSize(new Dimension(250, 150));
		chartPanel.setPreferredSize(new java.awt.Dimension(300, 200));
		this.add(new ChartPanel(chart));

		this.setPreferredSize(new Dimension(275, 175));
	}

	public static void main(String[] args) {
		JFrame frame = new JFrame();
		frame.getContentPane().add(new PieChart());
		frame.setSize(800, 600);
		frame.setVisible(true);
	}
}
